// pages/mine-item/mine-item-address/add.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    multiArray: [['一期宿舍', '二期宿舍', '三期宿舍', '四期宿舍', '五期宿舍'], ['1栋', '2栋', '3栋', '4栋', '5栋', '6栋', '7栋']],
    multiIndex: [0, 0,],  
    myAddress:{
      name:'',
      address:'一期宿舍,1栋',
      room:'',
      phone:''
    }
  },
  handleclick(){
    let name=this.data.name
    let room=this.data.room
    let phone=this.data.phone
    let address=this.data.address
    this.data.myAddress={name,room,phone,address}
    
    var app = getApp();
    var that = this;

    console.log(name,room,phone,address)
    if(name==''||room==''||phone==''){
      wx.showToast({
        title: '提交失败',
        icon:'none',
        duration: 2000
      })
    }else{
      app.globalData.myAddress = that.data.myAddress
      
      wx.showToast({
        title: '提交成功',
        icon:'success',
        duration: 2000
      })
      wx.navigateTo({
        url: '../mine-item-address/address'
      })
    }
    
    
  },
  handleinputroom(e){
    this.setData({
      room:e.detail.value
    })
  },
  handleinputname(e){
    
    this.setData({
      name:e.detail.value
    })
  },
  handleinput(e){
    
    this.setData({
      phone:e.detail.value
    })
  },
  bindMultiPickerChange: function (e) {
    console.log('picker发送选择改变，携带值为', e.detail.value)
    
    this.setData({
      multiIndex: e.detail.value,
      address:this.data.multiArray[0][this.data.multiIndex[0]]+","+this.data.multiArray[1][this.data.multiIndex[1]]
    })
    console.log(this.data.address)
    
  },
  bindMultiPickerColumnChange: function (e) {
    //console.log('修改的列为', e.detail.column, '，值为', e.detail.value);
    var data = {
      multiArray: this.data.multiArray,
      multiIndex: this.data.multiIndex
    };
    data.multiIndex[e.detail.column] = e.detail.value;
    
    switch(e.detail.column){
      case 0:
        switch (data.multiIndex[0]) {
          case 0:
            data.multiArray[1] = ['1栋', '2栋', '3栋', '4栋', '5栋', '6栋', '7栋'];
            break;
          case 1:
            data.multiArray[1] = ['9栋', '10栋', '11栋', '12栋', '13栋', '14栋', '15栋'];
            break;
          case 2:
            data.multiArray[1] = ['16栋', '17栋', '18栋', '19栋', '20栋', '21栋', '22栋'];
            break;
          case 3:
            data.multiArray[1] = ['23栋', '24栋', '25栋', '26栋', '27栋', '28栋'];
            break;
          case 4:
            data.multiArray[1] = ['29栋', '30栋'];
            break;            
        }
        data.multiIndex[1] = 0;
    }           
    //console.log(data.multiIndex);
    this.setData(data);
    //console.log(this.data.multiArray[0][this.data.multiIndex[0]]+","+this.data.multiArray[1][this.data.multiIndex[1]])
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})